home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 07 - 1991 / 07.09 Sep 91 / Generic Source ƒ / SecondConsole.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-03  |  3.1 KB  |  146 lines  |  [TEXT/KAHL]

  1. #pragma mark Header
  2. /***************************/
  3. /* SecondConsole.c
  4.     This handles all functions to
  5.     second console
  6.     6/5/91 - Created by Kirk Chase */
  7. /***************************/
  8.  
  9. #pragma mark #includes
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include <ctype.h>
  13. #include <console.h>
  14. #include "DebugAids.h"
  15.  
  16. #pragma mark Globals
  17. #ifdef THINK_C
  18. static FILE *printerConsole = NULL;
  19. #else
  20. static FILE *printerConsole = stdout;
  21. #endif
  22.  
  23. PrintTestPage(short pageType)
  24. {
  25. short i;
  26.  
  27. #ifdef THINK_C
  28. cshow(printerConsole);
  29. cecho2printer(printerConsole);
  30. #endif
  31.  
  32. if (pageType == 1) {
  33.     fprintf(printerConsole, "         1         2         3         4         5         6         7         8\n");
  34.     fprintf(printerConsole, "12345678901234567890123456789012345678901234567890123456789012345678901234567890\n");
  35.     for (i = 3; i<67; i++) fprintf(printerConsole,"%d\n", i);
  36.     return;
  37.     }
  38.  
  39. fprintf(printerConsole,"\t\tTest Page 2\t\tpg. 1\n");
  40.  
  41. #ifdef THINK_C
  42. cecho2printer(printerConsole); /* forces page break */
  43. #else
  44. fprintf(printerConsole, "\f");
  45. #endif
  46.  
  47. fprintf(printerConsole,"\t\tTest Page 2\t\tpg. 2\n");
  48. }
  49.  
  50. void ReadFile(short echo, FILE *con2)
  51. {
  52. char buffer[81];
  53. FILE *inputStream, *copyStream;
  54. short count;
  55.  
  56. #ifdef THINK_C
  57. cshow(con2); /* bring console to the front */
  58. cgotoxy(1, 1, con2);
  59. ccleos(con2);
  60. #endif
  61.  
  62. if (!(inputStream = fopen("Some Text", "r"))) { /* try to open input stream */
  63.     fprintf(stderr, "\n*** Error *** Could not open file \"Some Text\"\n");
  64.     
  65.     #ifdef THINK_C
  66.     chide(con2);
  67.     #endif
  68.     return;
  69.     }
  70.     
  71. if (echo)
  72.     if(!(copyStream = fopen("Some Text Copy", "w")) ) {
  73.         fprintf(stderr, "\n*** Error *** Could not open file \"Some Text Copy\"\n");
  74.         #ifdef THINK_C
  75.         chide(con2);
  76.         #endif
  77.         fclose(inputStream);
  78.         return;
  79.         }
  80.  
  81. while(!feof(inputStream)) { /* get input from inputStream, write to console */
  82.     count = fread(buffer, sizeof(char), 80, inputStream);
  83.     fwrite(buffer, sizeof(char), count, copyStream);
  84.     buffer[count] = '\0';
  85.     fprintf(con2, "%s", buffer);
  86.     }
  87. fprintf(con2, "\n");
  88. if (echo)
  89.     fclose(copyStream);
  90. fclose(inputStream); /* close input stream */
  91. }
  92.  
  93. SecondConsoleAd(FILE *con2)
  94. {
  95. #ifdef THINK_C
  96. cshow(con2);
  97. cgotoxy(1,1, con2);
  98. ccleos(con2);
  99.  
  100. fprintf(con2, "⁄ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒø\n");
  101. fprintf(con2, "≥ Ansi Style Font ≥\n");
  102. fprintf(con2, "¿ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒŸ\n");
  103. fprintf(con2, "\n");
  104. fprintf(con2, "€flflflflfl€ …=—=ª\n");
  105. fprintf(con2, "€∞YES∞€ ∫<≥>∫\n");
  106. fprintf(con2, "€‹‹‹‹‹€ »=œ=º\n");
  107. fprintf(con2, "\n");
  108.  
  109. fprintf(con2, "Press mouse button to continue...\n");
  110. while(!Button());
  111. chide(con2);
  112. #else
  113. fprintf(con2, ">>>> Get A Mac <<<<\n");
  114. #endif
  115. }
  116.  
  117. InitSecondConsole(FILE **con2)
  118. {
  119. short fnum;
  120. char consoleName[16]="\pSecond Console";
  121. char printerName[16]="\pPrinter Console";
  122. char pcFont[256] = "\ppcansi";
  123.  
  124. #ifdef THINK_C
  125. console_options.title = consoleName;
  126. console_options.top +=10;
  127. console_options.left +=10;
  128. GetFNum((Str255 *) pcFont, &fnum);
  129. if (fnum)
  130.     console_options.txFont = fnum;
  131. *con2 = fopenc();
  132. cinverse(FALSE, *con2);
  133.  
  134. console_options.title = printerName;
  135. console_options.txFont = monaco;
  136. console_options.top +=10;
  137. console_options.left +=10;
  138.  
  139. printerConsole = fopenc();
  140. chide(*con2);
  141. chide(printerConsole);
  142. #else
  143. *con2 = stdout;
  144. #endif
  145. }
  146.